package controller.api;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;

import common.inter.ServiserOnlyInter;
import model.Staff;
import service.StaffService;

@Before(ServiserOnlyInter.class)
public class ApiStaffController extends BaseApiController {
	@Inject StaffService staffService ;

	public void list() {
	    Kv kv = getParamKv() ;
	    kv.set("ts.servicerId" , getWxuser().getCompanyId());
	    Integer pageNumber = getParaToInt("pageNumber", 1);
	    Integer pageSize = getParaToInt("pageSize", 10);
	    set("page", staffService.getApiPage( kv , pageNumber, pageSize));
	    renderJson();
	}
	
	public void save() {
		Staff staff = getModel(Staff.class , "" , true);
		staff.keep("name","mobile","idcard","license");
		renderJson( staffService.save(staff , getWxuser()) );
	}
	
	public void remove() {
		Long id = getParaToLong("id");
		renderJson( staffService.remove( id , getWxuser() ) );
	}
}
